package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(value = OperationType.INSERT)
    void saveWithFavor(Dish dish);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    Dish getById(Long id);

    Page<DishVO> getPage(DishPageQueryDTO queryDTO);


    /**
     * 是否在售卖
     * */
    Integer isOnSale(List<Long> ids);

    //根据ids删除菜品
    void deleteByIds(List<Long> ids);

    // 根据分类id获取菜品列表
    List<DishVO> list(Long categoryId, Integer status);

    void status(Integer status, Long id);
}
